package com.block.channel.factory;

import com.block.channel.enums.ReportChannelEnum;
import com.block.channel.flow.IChannelReportService;
import com.block.channel.flow.channel.*;
import com.block.common.util.ApplicationContextUtil;

import java.util.HashMap;
import java.util.Map;

public class ReportChannelFactory {

    private static final Map<String, Class<? extends IChannelReportService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(ReportChannelEnum.SUOZHII.getValue(), SuoZhiChannelReportService.class);
        serviceMap.put(ReportChannelEnum.SUOZHII1.getValue(), SuoZhiChannelReportService.class);

        serviceMap.put(ReportChannelEnum.TUIA.getValue(), TuiAChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BIANXIANMAO.getValue(), BianXMChannelReportService.class);
        serviceMap.put(ReportChannelEnum.XIANGDIAN.getValue(), XiangDianChannelReportService.class);
        serviceMap.put(ReportChannelEnum.JIZHUN.getValue(), JiZhunChannelReportService.class);

        serviceMap.put(ReportChannelEnum.HUAWEI.getValue(), HuaWeiChannelReportService.class);
        serviceMap.put(ReportChannelEnum.VIVO.getValue(), VivoChannelReportService.class);
        serviceMap.put(ReportChannelEnum.XIAOMI.getValue(), XiaoMiChannelReportService.class);


        serviceMap.put(ReportChannelEnum.BAIDU001.getValue(), BaiDuChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BAIDU001LQB.getValue(), BaiDuChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BAIDU001KEJIE.getValue(), BaiDuChannelReportService.class);

        serviceMap.put(ReportChannelEnum.BAIDU002.getValue(), BaiDuH5ChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BAIDU003.getValue(), BaiDuH5ChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BAIDU004.getValue(), BaiDuH5ChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BAIDU005.getValue(), BaiDuH5ChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BAIDU006.getValue(), BaiDuH5ChannelReportService.class);

        serviceMap.put(ReportChannelEnum.RONGYAO.getValue(), RongYaoChannelReportService.class);



        //==============================================================================================================================
        serviceMap.put(ReportChannelEnum.HOUWNF.getValue(), BaiDuH5ChannelReportService.class);

    }

    public static IChannelReportService getService(String channelCode){
        if (serviceMap.containsKey(channelCode)){
            Class<? extends IChannelReportService> aClass = serviceMap.get(channelCode);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}
